import request from '@/config/axios'

// 仪器设备 VO
export interface DeviceVO {
  id: number // 主键
  deviceSiteCode: string//现场仪器编码
  deviceModeCode: string//仪器型号编码
  bdType: string // 仪器类型
  bdmype: string // 仪器型号
  factoryCode: string // 厂家编号
  remark: string // 备注
  state: boolean // 状态
  label: undefined,
  value : undefined,
  protocol: string // 协议
  port: string // 端口号
  ip: string // IP
}

// 仪器设备 API
export const DeviceApi = {
  // 查询仪器设备分页
  getDevicePage: async (params: any) => {
    return await request.get({ url: `/base/device/page`, params })
  },

  // 查询仪器设备详情
  getDevice: async (id: number) => {
    return await request.get({ url: `/base/device/get?id=` + id })
  },

  // 新增仪器设备
  createDevice: async (data: DeviceVO) => {
    return await request.post({ url: `/base/device/create`, data })
  },

  // 开始仪器设备
  startDevice: async (data: DeviceVO) => {
    return await request.put({ url: `/base/device/start`, data })
  },

  // 暂停仪器设备
  stopDevice: async (data: DeviceVO) => {
    return await request.put({ url: `/base/device/stop`, data })
  },

  // 修改仪器设备
  updateDevice: async (data: DeviceVO) => {
    return await request.put({ url: `/base/device/update`, data })
  },

  // 启用仪器设备
  enableDevice: async (id: number) => {
    return await request.get({ url: `/base/device/enable?id=` + id })
  },

  // 禁用仪器设备
  disableDevice: async (id: number) => {
    return await request.get({ url: `/base/device/disable?id=` + id })
  },


  // 删除仪器设备
  deleteDevice: async (id: number) => {
    return await request.delete({ url: `/base/device/delete?id=` + id })
  },

  // 导出仪器设备 Excel
  exportDevice: async (params) => {
    return await request.download({ url: `/base/device/export-excel`, params })
  },
  //获取仪器型号信息列表(字典为qy_model)
  getModeList: async (query: any) => {
    return await request.get({ url: `/system/dict-data/getdevicemode?params=` + query })
  },
//获取仪器型号信息列表(字典为yq_type)
  getModeListNew: async (query: any) => {
    return await request.get({ url: `/system/dict-data/getdevicemodenew?params=` + query })
  },

  // 下载用户导入模板
  importTemplate: async () => {
    return await request.download({ url: '/base/device/downTemplate' })
  },
  //导入excel数据
  reportDepartment: async (data) => {
    return await request.post({ url: '/base/device/reportDepartment', data })
  },
  //下载错误报告
  downloadWrongReport: async (data) => {
    return await request.download1({ url: '/base/device/downloadWrongReport', data })
  },






}
